Display : Display interface information
This module provides information about the current machine display interface and display status events. It is mainly used for EdgerOS related apps to obtain display interface information, such as cloud computer apps, set-top box apps and other apps that need display interfaces.
This module is provided in EdgerOS 1.8.0 and later, and apps need to have display
permission to use this module.
User can use the following code to import the Display
module.
var Display = require('display');
Support
The following shows Display
module APIs available for each permissions.
User Mode | Privilege Mode | |
---|---|---|
Display | ● | ● |
Display.list | ● | ● |
display.close | ● | ● |
display.info | ● | ● |
display.busy | ● | ● |
display.owner | ● | |
display.channel | ● | ● |
Display Class
new Display(channel)
channel
{Integer} Display channel number.- Returns: {Object} Display object.
Create a display object.
Example
var display = new Display(0);
Display.list()
- Returns: {Array} An array of valid display channel numbers.
Get an array of valid display channel numbers.
Example
console.log(Display.list());
Display Object
display.close()
Close the display object, this object is no longer available after it is closed.
display.info()
- Returns: {Object} Display information.
Get display interface information. This object contains the following members:
width
{Integer} Horizontal pixel width.high
{Integer} Vertical pixel width.color
{Integer} Color bits depth.linked
{Boolean} Is the monitor connected.busy
{Boolean} Is it occupied.
Example
var info = display.info();
if (info.linked) {
console.log(info.width, 'X', info.high);
}
display.busy()
- Returns: {Boolean} Is this display interface occupied.
Quickly get whether the current display interface is occupied.
Example
var busy = display.busy();
if (!busy) {
// Use this interface...
}
display.owner()
- Returns: {Integer} Process ID.
Get which process the display is being used by.
display.channel
- {Integer}
The channel number of the currently display object.
Display Class Events
Display
class inherit from EventEmitter
, The following events are thrown in some specific situations.
status
Display state may changed. It may be the linked status or the screen resolution, etc.
Example
Display.on('status', function(channel, linked) {
var display = new Display(channel);
var info = display.info();
//...
});
using
Display occupancy may changed.
Example
Display.on('using', function(channel) {
var display = new Display(channel);
var busy = display.busy();
if (!busy) {
//...
}
});